.class public Lcom/netease/netstat/utils/Util;
.super Ljava/lang/Object;
.source "Util.java"


# instance fields
.field private context:Landroid/content/Context;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 0
    .parameter "context"

    .prologue
    .line 19
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 20
    iput-object p1, p0, Lcom/netease/netstat/utils/Util;->context:Landroid/content/Context;

    .line 21
    return-void
.end method


# virtual methods
.method public checkTest(Ljava/lang/String;)I
    .locals 14
    .parameter "url"

    .prologue
    const/4 v12, 0x1

    const/4 v13, 0x0

    .line 54
    :try_start_0
    iget-object v0, p0, Lcom/netease/netstat/utils/Util;->context:Landroid/content/Context;

    invoke-static {v0}, Lcom/netease/util/HttpUtils;->getHttpClient(Landroid/content/Context;)Lorg/apache/http/client/HttpClient;

    move-result-object v0

    const/4 v2, 0x0

    const/4 v3, 0x0

    .line 55
    const-string v4, "GET"

    const/4 v5, 0x0

    const-string v6, "utf-8"

    move-object v1, p1

    .line 53
    invoke-static/range {v0 .. v6}, Lcom/netease/util/HttpUtils;->getHttpStringResult(Lorg/apache/http/client/HttpClient;Ljava/lang/String;Ljava/util/List;[Lorg/apache/http/Header;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v11

    .line 59
    .local v11, retText:Ljava/lang/String;
    iget-object v0, p0, Lcom/netease/netstat/utils/Util;->context:Landroid/content/Context;

    invoke-static {v0}, Lcom/netease/util/HttpUtils;->getHttpClient(Landroid/content/Context;)Lorg/apache/http/client/HttpClient;

    move-result-object v0

    invoke-interface {v0}, Lorg/apache/http/client/HttpClient;->getConnectionManager()Lorg/apache/http/conn/ClientConnectionManager;

    move-result-object v0

    invoke-interface {v0}, Lorg/apache/http/conn/ClientConnectionManager;->shutdown()V

    .line 60
    new-instance v9, Lorg/json/JSONObject;

    invoke-direct {v9, v11}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 61
    .local v9, json:Lorg/json/JSONObject;
    const-string v0, "main"

    invoke-virtual {v9, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v10

    .line 62
    .local v10, main:Ljava/lang/String;
    const-string v0, "downlink"

    invoke-virtual {v9, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    .line 64
    .local v7, downlink:Ljava/lang/String;
    const-string v0, "true"

    invoke-virtual {v10, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 65
    const/4 v0, 0x1

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    invoke-static {v0}, Lcom/netease/netstat/utils/Contanst;->setChecktest(Ljava/lang/Boolean;)V

    .line 69
    :goto_0
    const-string v0, "true"

    invoke-virtual {v7, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 70
    const/4 v0, 0x1

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    invoke-static {v0}, Lcom/netease/netstat/utils/Contanst;->setCheckdownlink(Ljava/lang/Boolean;)V

    :goto_1
    move v0, v12

    .line 78
    .end local v7           #downlink:Ljava/lang/String;
    .end local v9           #json:Lorg/json/JSONObject;
    .end local v10           #main:Ljava/lang/String;
    .end local v11           #retText:Ljava/lang/String;
    :goto_2
    return v0

    .line 67
    .restart local v7       #downlink:Ljava/lang/String;
    .restart local v9       #json:Lorg/json/JSONObject;
    .restart local v10       #main:Ljava/lang/String;
    .restart local v11       #retText:Ljava/lang/String;
    :cond_0
    const/4 v0, 0x0

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    invoke-static {v0}, Lcom/netease/netstat/utils/Contanst;->setChecktest(Ljava/lang/Boolean;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 75
    .end local v7           #downlink:Ljava/lang/String;
    .end local v9           #json:Lorg/json/JSONObject;
    .end local v10           #main:Ljava/lang/String;
    .end local v11           #retText:Ljava/lang/String;
    :catch_0
    move-exception v8

    .line 76
    .local v8, e:Ljava/lang/Exception;
    invoke-virtual {v8}, Ljava/lang/Exception;->printStackTrace()V

    move v0, v13

    .line 78
    goto :goto_2

    .line 72
    .end local v8           #e:Ljava/lang/Exception;
    .restart local v7       #downlink:Ljava/lang/String;
    .restart local v9       #json:Lorg/json/JSONObject;
    .restart local v10       #main:Ljava/lang/String;
    .restart local v11       #retText:Ljava/lang/String;
    :cond_1
    const/4 v0, 0x0

    :try_start_1
    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    invoke-static {v0}, Lcom/netease/netstat/utils/Contanst;->setCheckdownlink(Ljava/lang/Boolean;)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_1
.end method

.method public checkairline()V
    .locals 3

    .prologue
    const/4 v0, 0x0

    .line 26
    iget-object v1, p0, Lcom/netease/netstat/utils/Util;->context:Landroid/content/Context;

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    .line 27
    const-string v2, "airplane_mode_on"

    .line 25
    invoke-static {v1, v2, v0}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v1

    if-nez v1, :cond_0

    :goto_0
    sput-boolean v0, Lcom/netease/netstat/utils/Contanst;->airline:Z

    .line 28
    return-void

    .line 27
    :cond_0
    const/4 v0, 0x1

    goto :goto_0
.end method

.method public isNetworkAvailable()V
    .locals 6

    .prologue
    const/4 v5, 0x1

    .line 31
    iget-object v3, p0, Lcom/netease/netstat/utils/Util;->context:Landroid/content/Context;

    .line 32
    const-string v4, "connectivity"

    invoke-virtual {v3, v4}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    .line 31
    check-cast v0, Landroid/net/ConnectivityManager;

    .line 34
    .local v0, mConnMgr:Landroid/net/ConnectivityManager;
    invoke-virtual {v0, v5}, Landroid/net/ConnectivityManager;->getNetworkInfo(I)Landroid/net/NetworkInfo;

    move-result-object v2

    .line 36
    .local v2, mWifi:Landroid/net/NetworkInfo;
    const/4 v3, 0x0

    invoke-virtual {v0, v3}, Landroid/net/ConnectivityManager;->getNetworkInfo(I)Landroid/net/NetworkInfo;

    move-result-object v1

    .line 37
    .local v1, mMobile:Landroid/net/NetworkInfo;
    if-eqz v2, :cond_0

    invoke-virtual {v2}, Landroid/net/NetworkInfo;->isAvailable()Z

    move-result v3

    if-nez v3, :cond_1

    .line 38
    :cond_0
    if-eqz v2, :cond_3

    invoke-virtual {v1}, Landroid/net/NetworkInfo;->isAvailable()Z

    move-result v3

    if-eqz v3, :cond_3

    .line 39
    :cond_1
    invoke-virtual {v2}, Landroid/net/NetworkInfo;->isConnected()Z

    move-result v3

    if-nez v3, :cond_2

    invoke-virtual {v1}, Landroid/net/NetworkInfo;->isConnected()Z

    move-result v3

    if-eqz v3, :cond_3

    .line 40
    :cond_2
    sput-boolean v5, Lcom/netease/netstat/utils/Contanst;->connectivity:Z

    .line 43
    :cond_3
    return-void
.end method
